<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,viewport-fit=cover">
    <title>深i企-企业服务</title>
</head>
<body>
<div id="wxOpenInAPP" class="wexin-launch-btn"></div>
<script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script src="//www.sztv.com.cn/ysz/special_2020/js/jquery-1.8.0.min.js"></script>
<script>
    //判断是否是微信浏览器的函数
    var isWeiXin = function (){
        var ua = window.navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            return true;
        }else{
            return false;
        }
    }
    //如果是微信浏览器内打开
    if(isWeiXin()){
        //首先授权获取小程序标签wx-open-launch-weapp的使用权
        $.ajax({
            url: "https://api.scms.sztv.com.cn/api/weixin/jstoken",
            type: "GET",
            data: "url=" + encodeURIComponent(window.location.href) + "&siteId=67",
            dataType: "jsonp",
            async: false,
            jsonpCallback: "success_jsonpCallback",
            success: function(data) {
                wx.config({
                    //debug: true,
                    appId: data.appId,
                    timestamp: data.timestamp,
                    nonceStr: data.noncestr,
                    signature: data.signature,
                    jsApiList: ['onMenuShareAppMessage'],
                    openTagList: ['wx-open-launch-weapp'] //获取微信小程序的标签使用权
                });
                wx.ready(function() {
                    var dom = document.getElementById('wxOpenInAPP');
                    //username为需要跳转的小程序原始ID
                    //path为小程序的首页路径
                    dom.innerHTML = '<wx-open-launch-weapp id="launch-btn" username="gh_d2b06f77ef8d" path="pages/index/index"><template><style>.wx-btn {font-size:16px; width:250px; height:60px; display: block; margin-top:10px;margin-left:50px; }</style><button class="wx-btn">深i企-企业服务</button></template></wx-open-launch-weapp>';
                    var launchBtn = document.getElementById('launch-btn') ;
                    if (!launchBtn) { return };
                    launchBtn.addEventListener('launch', function (e) { console.log('eee',e); });
                    launchBtn.addEventListener('error', function (e) { console.log('fail', e.detail) });
                })
            }
        })
//如果是壹深圳APP或其他非微信浏览器打开
    }else{
        var tn = document.getElementById('wxOpenInAPP');
        tn.innerHTML = '<div style="font-size:16px;width:250px;height:60px;">深i企-企业服务</div>';
        tn.onclick = function(e) {
            location.href = "https://www.sztv.com.cn/huodong/sj/zxcv/jump.php";
            //点击事件
            e.stopPropagation(); // 阻止冒泡到父级的点击事件
        }
    }
</script>
</body>
</html>